In the last video we have learned how to down sample a time series from high frequency to low frequency.
And we can do this service of the three sample method which is a quite powerful and versatile method.
However there is one thing that is quite inconvenient and that can cause some confusion.
So we have still imparted our temperature data frame with the hourly temperature data and we can actually
convert the frequency from our lead to monthly and we take the mean here.
So this is nothing new.
And if we have for the monthly mean temperature far less angels than New York for each month here and
actually the values here are the mean over ALL TIMESTAMPS in the complete month.
So here we are for the complete month that January to 13.
And for example here eleven point five nine degrees is actually the average of all time stamps in January.
So these values are kind of aggregated data for a period.
So you have for a one month period.
However as a label for the period we have here one day so year at the very last day of the period.
So the thirty first of January and actually the recital method gives us some options here to change
the arrow label or index label so for example instead of having you know the month and we can also have
year the beginning of each month
so you can see instead of having the thirty first of January we have the very first day of January.
So so the aggregated values here are the same.
So these are the mean values for example here for the whole January and we only can change here the
label.
So either we can take the first day or the last day off the period but still here as a label we have
a day and not actually a month and this is kind of inconvenient because we have monthly data for the
whole January and as a label we have one day of January.
So actually it would be better to a simply half year January 213 and ESA the re sample method is quite
versatile.
We can also define this year.
So let's have a look here and here we have to compare me to kind.
So let's have a look at the documentation so the default setting is then on and if it can pass the time
stamp to convert the resulting index to a date time index all we can pass period to convert it to a
period index and by default that the input representation is retained.
So here the input representation of our original temperature data frame is actually a daytime index
and therefore he and our resolve but an aggregate data frame we have here a daytime index this the specific
days and actually now our target would be to convert our next year into a period index.
So let's call here the parameter kind and actually we can either choose a timestamp.
So this is here in our example the default setting actually.
And we can see that.
We get the single timestamps So yeah for the period January we have January the 1st.
And again if you change year from and start to M so month ending then we have here the thirty first
of January the but still this is pretty inconvenient and therefore we pass here the argument period
to the kind parameter so let's try this out here
and now here we can see in our first row instead of having a particular day and January 213 we simply
have it and you read 213 and I think this is a clearer representation of our row because he and our
row we have the aggregated data from January.
So from all days and now here we have the label January.
So this is quite convenient and does not to cause any confusion here.
And actually the same we can do also with other frequency.
So for example for weekly frequency.
So let's try this out here and for weekly frequencies we actually get here as labels.
Let's start off the week and actually the end of the week and by default if you pass the only w then
the start of the week is a Monday and the end of the week is a Sunday and still in addition we can define
you whether we want to have weeks from Monday to Sunday or from Thursday to Wednesday whatever.
So this is C a completely flexible.
And let's go to quarterly
and we can see on the left hand side in the index as in next Lavers and set off having the very first
day or the very last day off the quarter.
Now we have from Q1 into 13 Q2 and so on.
So this is definitely more intuitive than having one single day of the quarter.
All right and last but not least we can also change um the frequency to Anya
and we simply have on the left hand side and the year so to 13 to 14 to 15.
And also here this is more intuitive than having here a single day of the year.
All right.
Now let's convert the frequency of our temperature data frame to a monthly and we pass period to the
kind parameter and we take the mean and we store the aggregate data frame in the rabbit temperature.
Uh monthly and let's have a look at our new data frame.
So here we have the monthly temperature.
And on the left hand side.
Yeah.
We do not have a date time index with a specific day but the FAA period index indicating the periods
of our data frame.
So here we have the aggregate data for January and we have January and we can also call here the Inform
method and we can see here instead of having a daytime index we now have a period indexed with the 48
entries.
So we have 48 months from January to 30 into December to a 16 with a monthly frequency and we can also
call the index attribute and we can see that we have a period index and we have all of these specific
periods.
So January to 30 in February to 13 and so on and we can also select a single element.
So for example the very first element and this was c a not a timestamp but a period.
So we have here January 213 and the frequency is month.
All right let's plot again our data and first of all we plot our original data frame with our data and
we can see here that this is actually quite messy.
So we have many data points and as the FBI our data we FBI the daily oscillations so from day to night
and by down sampling our data we can actually smooth our data.
So by down sampling it from our lead to monthly we can actually remove the daily oscillation of fluctuation
between day and night and therefore let's plot here our new aggregated data frame temperature monthly
and we can see that we have smooth and our data.
So here we have clear lines this monthly data our monthly averages and year by smoothing the line plots.
We can see even better that we have some seasonality.
So the summers are warmer than the winter us and we cannot really say that the summers in L.A. are warmer
than in New York.
So the temperatures here are quite similar but it's quite significant that the vendors in New York are
much colder than the vendors in Los Angeles here.
All right we are finished now with this video and I hope to see also in the next one by.